<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:useBean
        id="messagePreview"
        class="org.goldfish.message_board01.entity.MessagePreview"
        scope="request"
/>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>留言详情</title>
</head>
<body>
<h2>留言详情</h2>
<div>
    <c:set var="messageLines" value="${requestScope.get('messageDetails')}"/>
    <c:set var="messageInfo" value="${requestScope.get('messagePreview')}"/>
    <!-- Display message details -->
    <c:choose>
        <c:when test="${empty messageInfo}">
            <p>没有找到留言</p>
        </c:when>
        <c:otherwise>
            <h1>${messageInfo.title}</h1>
            <p>发送方: ${messageInfo.sender} <br>发送于 ${messageInfo.time}</p>
        </c:otherwise>
    </c:choose>
    <div>
        <c:choose>
            <c:when test="${empty messageLines}">
                <p>(没有内容)</p>
            </c:when>
            <c:otherwise>
                <p>内容:</p>
                <c:forEach var="line" items="${messageLines}">
                    <p>${line}</p>
                </c:forEach>
            </c:otherwise>
        </c:choose>
    </div>

    <a href="messages">看完了</a>

</div>
</body>
</html>